<template>
    <el-dialog
        :title="dialogTitle"
        :visible.sync="dialogVisible"
        width="70%"
        @closed="closedHandle">
        <component :is="map" :param="{navigationControl:true,mapHeight:500,scrollWheelZoom:true}" >
            <slot v-bind:data-source="dataSource"></slot>
        </component>

        <span slot="footer" class="dialog-footer" v-if="childCompName=='addRoads'">
            <el-button @click="dialogVisible = false" size="small">取 消</el-button>
            <el-button type="primary" @click="confirmHandle"  size="small" >确 定</el-button>
        </span>
    </el-dialog>
</template>
<script>
    import BMapComp from "@/components/BMapComp"
    import HashMap from "@/utils/hashmap"
    export default{
        name:'mapDialog',
        data(){
            return {
                dialogVisible:false,
                HashMap:new HashMap(),
                roadsName:[],
                routeList:[],
                childCompName:'',
                map:'',
                dialogTitle:''
            }
        },
        props:{
            "routes":{
                type:Array,
                default:function(){
                    return  [];
                }
            },
            "childComp":{
                type:String,
                default:''
            },
            "title":{
                type:String,
                default:'查看开锁位置'
            },
            "dataSource":{
                type:Object,
                defualt:function(){
                    return {};
                }
            }
        },
        components:{
            BMapComp
        },
        created() {
            this.showMap();
            this.childCompName = this.$props.childComp;
            this.dialogTitle = this.$props.title;
        },
        methods:{

            //确定按钮事件
            confirmHandle(){
                this.dialogVisible = false;
            },
            //显示地图
            showMap(){
                this.map = 'BMapComp';
                this.dialogVisible = true;
            },

            //隐藏弹窗回调
            closedHandle(){
                this.map = '';
            },


        }
    }
</script>
<style>

</style>
